#include "kit/tool/Tokenizer.hpp"

namespace KitTool
{
	std::vector<std::string> Tokenizer::tokenize(const std::string & iInput, const char iDelimeter)
	{
		int aTokenBegin = 0;
		std::vector<std::string> aTokens;
		for(int i = 0; i < iInput.size(); ++i)
		{
			if(iInput[i] == iDelimeter)
			{
				std::string aNewToken = iInput.substr(aTokenBegin, i - aTokenBegin);

				aTokens.push_back(aNewToken);
				aTokenBegin = i + 1;
			}
		}
		// the last one is also a token
		std::string aNewToken = iInput.substr(aTokenBegin, iInput.size() - aTokenBegin);
		aTokens.push_back(aNewToken);
		return aTokens;
	}
}
